'''
二分类TP,TN,FP,FN计算
二分类混淆矩阵计算
二分类ROC曲线绘制
二分类PR曲线绘制
'''


import matplotlib.pyplot as plt
from sklearn.metrics import confusion_matrix, classification_report, roc_curve, auc, precision_recall_curve, average_precision_score
import numpy as np
import pandas as pd


# 二分类：概率结果依据人工设定分类阈值计算TP、TN、FP、FN
def base(y, preds, threshold):
    '''
    :param y: 真实标签
    :param preds: 预测概率
    :param threshold: 判定为正例的阈值
    :return: TP,TN,FP,FN
    '''

    preds = np.asarray(preds, dtype=np.float)
    y_preds = (preds >= threshold) * 1
    tp = 0
    tn = 0
    fp = 0
    fn = 0
    for i in range(len(y)):
        if y[i] == y_preds[i]:
            if y[i] == 0:
                tn = tn+1
            else:
                tp = tp+1
        else:
            if y[i] == 0:
                fp = fp+1
            else:
                fn = fn+1

    return tp, tn, fp, fn


# 二分类：概率结果根据分类阈值计算混淆矩阵
def my_confusion_matrix(y, preds, threshold):
    '''

    :param y: 真实标签
    :param preds: 预测概率
    :param threshold: 判定为正例的阈值
    :return: confusion matrix for binary classfication
    '''
    y_preds = (preds >= threshold) * 1

    result = confusion_matrix(y, y_preds)

    return result


# 二分类：概率结果根据分类阈值计算评估指标
def my_classfication_report(y, preds, threshold):
    '''

    :param y: 真实标签
    :param preds: 预测概率
    :param threshold: 判定为正例的阈值
    :return: classfication report for binary classfication
    '''
    y_preds = (preds >= threshold) * 1

    target_names = ['1', '2']

    print(y)
    print(y_preds)

    result = classification_report(y_true=y, y_pred=y_preds, target_names=target_names)

    return result


# 二分类：绘制单一模型 ROC曲线
def auc_curve(y, prob):
    '''

    :param y: 真实标签
    :param prob: 预测概率
    :return: 打印ROC曲线
    '''
    fpr, tpr, threshold = roc_curve(y, prob)
    roc_auc = auc(fpr, tpr)

    # for i in range(len(fpr)):
    #     print('FPR: {0}-->TPR: {1}-->threshold: {2}'.format(fpr[i], tpr[i], threshold[i]))


    lw = 2
    plt.figure(figsize=(10, 10))
    plt.plot(fpr, tpr, color='darkorange', lw=lw, label='ROC curve (area=%0.3f)' % roc_auc)
    plt.plot([0, 1], [0, 1], color='navy', lw=lw, linestyle='--')
    plt.plot([1, 0], [0, 1], color='navy', lw=lw, linestyle='--')
    # 绘制医生的诊断效果点
    plt.plot([0.217], [0.686], marker='o', color='red')
    # 绘制二分类决策树效果点
    plt.plot([0.358], [0.686], marker='o', color='green')

    plt.xlim([0.0, 1.0])
    plt.ylim([0.0, 1.05])
    plt.xlabel('False Positive Rate')
    plt.ylabel('True Positive Rate')
    plt.title('AUC')
    plt.legend(loc='lower right')
    plt.savefig('D:/lung_cancer/pytorch_code/two_roc_manifold.png')
    plt.show()



# 二分类：绘制单一模型 P-R曲线
def pr_curve(y, prob):
    '''

    :param y: 真实标签
    :param prob: 预测概率
    :return: 打印P-R曲线
    '''
    average_precision = average_precision_score(y, prob)
    precision, recall, threshold = precision_recall_curve(y, prob)
    plt.step(recall, precision, color='b', alpha=0.2, where='post')
    plt.fill_between(recall, precision, step='post', alpha=0.2, color='b')
    # 绘制医生的诊断效果点
    plt.plot([0.686], [0.48], marker='o', color='red')
    # 绘制二分类决策树效果点
    plt.plot([0.686], [0.36], marker='o', color='green')

    plt.xlabel('Recall')
    plt.ylabel('Precision')
    plt.ylim([0.0, 1.05])
    plt.xlim([0.0, 1.0])
    plt.title('2-class Precision-Recall curve: AP={0:0.2f}'.format(average_precision))

    plt.show()


# 在一张图上绘制二分类模型ROC曲线
# 前提：已将各模型分类结果保存下来
# 二分类：绘制多模型ROC曲线
def two_roc_curve():
    # print('hello')
    # 读取xgboost分类结果
    xgboost_labels = np.load('D:/lung_cancer/data/two_result/two_xgboost_labels.npy')
    xgboost_preds = np.load('D:/lung_cancer/data/two_result/two_xgboost_preds.npy')
    xgfpr, xgtpr, xgthreshold = roc_curve(xgboost_labels, xgboost_preds)
    xgroc_auc = auc(xgfpr, xgtpr)

    # 读取使用中心坐标的xgboost分类结果
    center_xgboost_labels = np.load('D:/lung_cancer/data/two_result/two_xgboost_new_labels.npy')
    center_xgboost_preds = np.load('D:/lung_cancer/data/two_result/two_xgboost_new_preds.npy')
    c_xgfpr, c_xgtpr, c_xgthreshold = roc_curve(center_xgboost_labels, center_xgboost_preds)
    c_xgroc_auc = auc(c_xgfpr, c_xgtpr)

    # 读取使用w,h的xgboost分类结果
    wh_xgboost_labels = np.load('D:/lung_cancer/data/two_result/two_xgboost_wh_labels.npy')
    wh_xgboost_preds = np.load('D:/lung_cancer/data/two_result/two_xgboost_wh_preds.npy')
    wh_xgfpr, wh_xgtpr, wh_xgthreshold = roc_curve(wh_xgboost_labels, wh_xgboost_preds)
    wh_xgroc_auc = auc(wh_xgfpr, wh_xgtpr)

    # 读取使用w,h, newx, newy 的xgboost分类结果
    whxy_xgboost_labels = np.load('D:/lung_cancer/data/two_result/two_xgboost_whxy_labels.npy')
    whxy_xgboost_preds = np.load('D:/lung_cancer/data/two_result/two_xgboost_whxy_preds.npy')
    whxy_xgfpr, whxy_xgtpr, whxy_xgthreshold = roc_curve(whxy_xgboost_labels, whxy_xgboost_preds)
    whxy_xgroc_auc = auc(whxy_xgfpr, whxy_xgtpr)

    # 读取SVM分类结果
    svm_labels = np.load('D:/lung_cancer/data/two_result/two_svm_labels.npy')
    svm_preds = np.load('D:/lung_cancer/data/two_result/two_svm_preds.npy')
    svmfpr, svmtpr, svmthreshold = roc_curve(svm_labels, svm_preds)
    svmroc_auc = auc(svmfpr, svmtpr)

    # 读取LR分类结果
    lr_labels = np.load('D:/lung_cancer/data/two_result/two_LR_labels.npy')
    lr_preds = np.load('D:/lung_cancer/data/two_result/two_LR_preds.npy')
    lrfpr, lrtpr, lrthreshold = roc_curve(lr_labels, lr_preds)
    lrroc_auc = auc(lrfpr, lrtpr)

    # 读取MLP分类结果
    mlp_labels = np.load('D:/lung_cancer/two_MLP_labels.npy')
    mlp_preds = np.load('D:/lung_cancer/two_MLP_preds.npy').flatten()
    mlpfpr, mlptpr, mlpthreshold = roc_curve(mlp_labels, mlp_preds)
    mlproc_auc = auc(mlpfpr, mlptpr)

    # 读取MLP center 分类结果
    c_mlp_labels = np.load('D:/lung_cancer/data/two_result/two_MLP_info_center_labels.npy')
    c_mlp_preds = np.load('D:/lung_cancer/data/two_result/two_MLP_info_center_preds.npy').flatten()
    c_mlpfpr, c_mlptpr, c_mlpthreshold = roc_curve(c_mlp_labels, c_mlp_preds)
    c_mlproc_auc = auc(c_mlpfpr, c_mlptpr)

    # 读取 manifold 分类结果
    manifold_labels = np.load('D:/lung_cancer/pytorch_code/two_result/two_manifold_labels.npy')
    manifold_preds = np.load('D:/lung_cancer/pytorch_code/two_result/two_manifold_preds.npy')
    manfpr, mantpr, manthreshold = roc_curve(manifold_labels, manifold_preds)
    manroc_auc = auc(manfpr, mantpr)

    # 读取 remix 分类结果
    remix_labels = np.load('D:/lung_cancer/pytorch_code/two_result/two_remix_labels.npy')
    remix_preds = np.load('D:/lung_cancer/pytorch_code/two_result/two_remix_preds.npy')
    remfpr, remtpr, remthreshold = roc_curve(remix_labels, remix_preds)
    remroc_auc = auc(remfpr, remtpr)


    # print(remfpr)
    # print(remtpr)
    # print(remthreshold)

    # 初始化图
    lw = 1.5
    plt.figure(figsize=(10, 10))
    # 绘制斜对角线（模型效果一般在对角线左上方）
    plt.plot([0, 1], [0, 1], color='brown', lw=lw, linestyle='--')

    # xgboost分类结果
    # plt.plot(xgfpr, xgtpr, color='darkorange', lw=lw, label='Xgboost ROC curve (area=%0.3f)' % xgroc_auc)

    # center坐标xgboost分类结果
    # plt.plot(c_xgfpr, c_xgtpr, color='yellow', lw=lw, label='center Xgboost ROC curve (area=%0.3f)' % c_xgroc_auc)

    # 使用wh的xgboost分类结果
    plt.plot(wh_xgfpr, wh_xgtpr, color='darkmagenta', lw=lw, linestyle='--', label='Xgboost ROC curve (area=%0.3f)' % wh_xgroc_auc)

    # 使用whxy的xgboost分类结果
    # plt.plot(whxy_xgfpr, whxy_xgtpr, color='crimson', lw=lw, label='whxy Xgboost ROC curve (area=%0.3f)' % whxy_xgroc_auc)

    # SVM分类结果
    # plt.plot(svmfpr, svmtpr, color='green', lw=lw, marker='1', label='SVM ROC curve (area=%0.3f)' % svmroc_auc)

    # LR分类结果
    # plt.plot(lrfpr, lrtpr, color='darkblue', lw=lw, marker='>', label='LR ROC curve (area=%0.3f)' % lrroc_auc)

    # MLP分类结果
    # plt.plot(mlpfpr, mlptpr, color='aquamarine', lw=lw, label='MLP ROC curve (area=%0.3f)' % mlproc_auc)

    # center MLP分类结果
    plt.plot(c_mlpfpr, c_mlptpr, color='black', lw=lw, linestyle='-.', label='MLP ROC curve (area=%0.3f)' % c_mlproc_auc)

    # manifold 分类结果
    # plt.plot(c_mlpfpr, c_mlptpr, color='aquamarine', lw=lw, linestyle='-.', label='Manfold ROC curve (area=%0.3f)' % manroc_auc)
    #
    # remix分类结果
    # plt.plot(remfpr, remtpr, color='crimson', lw=lw, linestyle='-.', label='Remix ROC curve (area=%0.3f)' % remroc_auc)

    # 绘制医生的诊断效果点
    plt.plot([0.217], [0.686], marker='*', color='red', label='doctor')
    # 绘制二分类决策树效果点
    plt.plot([0.358], [0.686], marker='o', color='black', label='decision tree')

    plt.xlim([0.0, 1.0])
    plt.ylim([0.0, 1.05])
    plt.xlabel('False Positive Rate')
    plt.ylabel('True Positive Rate')
    plt.title('AUC')
    plt.legend(loc='lower right')

    # plt.savefig('D:/lung_cancer/two_roc.png')

    plt.show()



# 在一张图上绘制二分类模型ROC曲线
# 前提：已将各模型分类结果保存下来
# 二分类：绘制多模型ROC曲线
# 绘制人工提取特征的部分模型效果
def two_roc_curve2():
    print('hello')

    # 读取使用w,h的xgboost分类结果
    wh_xgboost_labels = np.load('D:/lung_cancer/data/two_result/two_xgboost_wh_labels.npy')
    wh_xgboost_preds = np.load('D:/lung_cancer/data/two_result/two_xgboost_wh_preds.npy')
    wh_xgfpr, wh_xgtpr, wh_xgthreshold = roc_curve(wh_xgboost_labels, wh_xgboost_preds)
    wh_xgroc_auc = auc(wh_xgfpr, wh_xgtpr)


    # 读取SVM分类结果
    svm_labels = np.load('D:/lung_cancer/data/two_result/two_svm_labels.npy')
    svm_preds = np.load('D:/lung_cancer/data/two_result/two_svm_preds.npy')
    svmfpr, svmtpr, svmthreshold = roc_curve(svm_labels, svm_preds)
    svmroc_auc = auc(svmfpr, svmtpr)

    # 读取LR分类结果
    lr_labels = np.load('D:/lung_cancer/data/two_result/two_LR_labels.npy')
    lr_preds = np.load('D:/lung_cancer/data/two_result/two_LR_preds.npy')
    lrfpr, lrtpr, lrthreshold = roc_curve(lr_labels, lr_preds)
    lrroc_auc = auc(lrfpr, lrtpr)


    # 读取MLP center 分类结果
    c_mlp_labels = np.load('D:/lung_cancer/data/two_result/two_MLP_info_center_labels.npy')
    c_mlp_preds = np.load('D:/lung_cancer/data/two_result/two_MLP_info_center_preds.npy').flatten()
    c_mlpfpr, c_mlptpr, c_mlpthreshold = roc_curve(c_mlp_labels, c_mlp_preds)
    c_mlproc_auc = auc(c_mlpfpr, c_mlptpr)


    # 初始化图
    lw = 1.5
    plt.figure(figsize=(10, 10))
    # 绘制斜对角线（模型效果一般在对角线左上方）
    plt.plot([0, 1], [0, 1], color='brown', lw=lw, linestyle='--')

    # SVM分类结果
    plt.plot(svmfpr, svmtpr, color='green', lw=lw, linestyle='--', label='SVM ROC curve (area=%0.3f)' % svmroc_auc)

    # LR分类结果
    plt.plot(lrfpr, lrtpr, color='darkblue', lw=lw, linestyle='--', label='LR ROC curve (area=%0.3f)' % lrroc_auc)

    # 使用wh的xgboost分类结果
    plt.plot(wh_xgfpr, wh_xgtpr, color='darkmagenta', lw=lw, linestyle='--', label='Xgboost ROC curve (area=%0.3f)' % wh_xgroc_auc)

    # center MLP分类结果
    plt.plot(c_mlpfpr, c_mlptpr, color='black', lw=lw, linestyle='-.', label='MLP ROC curve (area=%0.3f)' % c_mlproc_auc)

    # 绘制医生的诊断效果点
    plt.plot([0.217], [0.686], marker='*', color='red', label='doctor')
    # 绘制二分类决策树效果点
    plt.plot([0.358], [0.686], marker='o', color='black', label='decision tree')

    plt.xlim([0.0, 1.0])
    plt.ylim([0.0, 1.05])
    plt.xlabel('False Positive Rate')
    plt.ylabel('True Positive Rate')
    plt.title('AUC')
    plt.legend(loc='lower right')

    plt.savefig('D:/lung_cancer/two_artificial_roc.png')

    plt.show()


# 在一张图上绘制二分类模型ROC曲线
# 前提：已将各模型分类结果保存下来
# 二分类：绘制多模型ROC曲线
# 绘制自动提取特征的部分模型效果
def two_roc_curve3():
    print('hello')

    # 读取 manifold 分类结果
    manifold_labels = np.load('D:/lung_cancer/pytorch_code/two_result/two_manifold_labels.npy')
    manifold_preds = np.load('D:/lung_cancer/pytorch_code/two_result/two_manifold_preds.npy')
    manfpr, mantpr, manthreshold = roc_curve(manifold_labels, manifold_preds)
    manroc_auc = auc(manfpr, mantpr)

    # 读取 remix 分类结果
    remix_labels = np.load('D:/lung_cancer/pytorch_code/two_result/two_remix_labels.npy')
    remix_preds = np.load('D:/lung_cancer/pytorch_code/two_result/two_remix_preds.npy')
    remfpr, remtpr, remthreshold = roc_curve(remix_labels, remix_preds)
    remroc_auc = auc(remfpr, remtpr)

    # 读取 other+manifold(1.2) 分类结果
    other_manifold_labels = np.load('D:/lung_cancer/pytorch_code/two_result/two_other_maniflod_1.2_labels.npy')
    other_manifold_preds = np.load('D:/lung_cancer/pytorch_code/two_result/two_other_manifold_1.2_preds.npy')
    other_manfpr, other_mantpr, other_manthreshold = roc_curve(other_manifold_labels, other_manifold_preds)
    other_manroc_auc = auc(other_manfpr, other_mantpr)

    # 读取 other+remix(0.2) 分类结果
    other_remix_labels = np.load('D:/lung_cancer/pytorch_code/two_result/two_other_remix_0.2_labels.npy')
    other_remix_preds = np.load('D:/lung_cancer/pytorch_code/two_result/two_other_remix_0.2_preds.npy')
    other_remfpr, other_remtpr, other_remthreshold = roc_curve(other_remix_labels, other_remix_preds)
    other_remroc_auc = auc(other_remfpr, other_remtpr)



    # 初始化图
    lw = 1.5
    plt.figure(figsize=(10, 10))
    # 绘制斜对角线（模型效果一般在对角线左上方）
    plt.plot([0, 1], [0, 1], color='brown', lw=lw, linestyle='--')

    # other+manifold(1.2)分类结果
    plt.plot(other_manfpr, other_mantpr, color='darkmagenta', lw=lw, linestyle='--', label='other+manifold ROC curve (area=%0.3f)' % other_manroc_auc)

    # other+remix(0.2)分类结果
    plt.plot(other_remfpr, other_remtpr, color='black', lw=lw, linestyle='-.', label='other+remix ROC curve (area=%0.3f)' % other_remroc_auc)

    # manifold 分类结果
    plt.plot(manfpr, mantpr, color='aquamarine', lw=lw, linestyle='-.', label='Manifold ROC curve (area=%0.3f)' % manroc_auc)
    #
    # remix分类结果
    plt.plot(remfpr, remtpr, color='crimson', lw=lw, linestyle='-.', label='Remix ROC curve (area=%0.3f)' % remroc_auc)

    # 绘制医生的诊断效果点
    plt.plot([0.217], [0.686], marker='*', color='red', label='doctor')


    plt.xlim([0.0, 1.0])
    plt.ylim([0.0, 1.05])
    plt.xlabel('False Positive Rate')
    plt.ylabel('True Positive Rate')
    plt.title('AUC')
    plt.legend(loc='lower right')

    plt.savefig('D:/lung_cancer/two_auto_roc.png')

    plt.show()




# 在一张图上绘制二分类模型P-R曲线
# 前提：已将各模型分类结果保存下来
# 二分类：绘制多模型PR曲线
def two_pr_curve():
    print('hello')
    # 读取xgboost分类结果
    xgboost_labels = np.load('D:/lung_cancer/data/two_result/two_xgboost_labels.npy')
    xgboost_preds = np.load('D:/lung_cancer/data/two_result/two_xgboost_preds.npy')
    xg_average_precision = average_precision_score(xgboost_labels, xgboost_preds)
    xg_precision, xg_recall, xg_threshold = precision_recall_curve(xgboost_labels, xgboost_preds)

    # 读取使用中心坐标的xgboost分类结果
    center_xgboost_labels = np.load('D:/lung_cancer/data/two_result/two_xgboost_new_labels.npy')
    center_xgboost_preds = np.load('D:/lung_cancer/data/two_result/two_xgboost_new_preds.npy')
    cxg_average_precision = average_precision_score(center_xgboost_labels, center_xgboost_preds)
    cxg_precision, cxg_recall, cxg_threshold = precision_recall_curve(center_xgboost_labels, center_xgboost_preds)

    # 读取使用wh的xgboost分类结果
    wh_xgboost_labels = np.load('D:/lung_cancer/data/two_result/two_xgboost_wh_labels.npy')
    wh_xgboost_preds = np.load('D:/lung_cancer/data/two_result/two_xgboost_wh_preds.npy')
    whxg_average_precision = average_precision_score(wh_xgboost_labels, wh_xgboost_preds)
    whxg_precision, whxg_recall, whxg_threshold = precision_recall_curve(wh_xgboost_labels, wh_xgboost_preds)

    # 读取使用whxy的xgboost分类结果
    whxy_xgboost_labels = np.load('D:/lung_cancer/data/two_result/two_xgboost_whxy_labels.npy')
    whxy_xgboost_preds = np.load('D:/lung_cancer/data/two_result/two_xgboost_whxy_preds.npy')
    whxyxg_average_precision = average_precision_score(whxy_xgboost_labels, whxy_xgboost_preds)
    whxyxg_precision, whxyxg_recall, whxyxg_threshold = precision_recall_curve(whxy_xgboost_labels, whxy_xgboost_preds)

    # 读取SVM分类结果
    svm_labels = np.load('D:/lung_cancer/data/two_result/two_svm_labels.npy')
    svm_preds = np.load('D:/lung_cancer/data/two_result/two_svm_preds.npy')
    svm_average_precision = average_precision_score(svm_labels, svm_preds)
    svm_precision, svm_recall, svm_threshold = precision_recall_curve(svm_labels, svm_preds)

    # 读取LR分类结果
    lr_labels = np.load('D:/lung_cancer/data/two_result/two_LR_labels.npy')
    lr_preds = np.load('D:/lung_cancer/data/two_result/two_LR_preds.npy')
    lr_average_precision = average_precision_score(lr_labels, lr_preds)
    lr_precision, lr_recall, lr_threshold = precision_recall_curve(lr_labels, lr_preds)

    # 读取MLP分类结果
    mlp_labels = np.load('D:/lung_cancer/data/two_result/two_MLP_info_labels.npy')
    mlp_preds = np.load('D:/lung_cancer/data/two_result/two_MLP_info_preds.npy').flatten()
    mlp_average_precision = average_precision_score(mlp_labels, mlp_preds)
    mlp_precision, mlp_recall, mlp_threshold = precision_recall_curve(mlp_labels, mlp_preds)

    # 读取MLP center 分类结果
    c_mlp_labels = np.load('D:/lung_cancer/data/two_result/two_MLP_info_center_labels.npy')
    c_mlp_preds = np.load('D:/lung_cancer/data/two_result/two_MLP_info_center_preds.npy').flatten()
    c_mlp_average_precision = average_precision_score(c_mlp_labels, c_mlp_preds)
    c_mlp_precision, c_mlp_recall, c_mlp_threshold = precision_recall_curve(c_mlp_labels, c_mlp_preds)


    # 绘制斜对角线（模型效果一般在对角线左上方）
    plt.plot([1, 0], [0, 1], color='brown', linestyle='--')

    # plt.step(xg_recall, xg_precision, color='b', alpha=0.2, where='post')
    # plt.fill_between(xg_recall, xg_precision, step='post', alpha=0.2, color='b')
    # 绘制医生的诊断效果点
    plt.plot([0.686], [0.48], marker='o', color='red', label='doctor')
    # 绘制二分类决策树效果点
    plt.plot([0.686], [0.36], marker='o', color='black', label='decision tree')

    lw = 1
    # xgboost分类结果
    # plt.plot(xg_recall, xg_precision, color='darkorange', lw=lw, label='Xgb pr curve (area=%0.3f)' % xg_average_precision)

    # center坐标xgboost分类结果
    # plt.plot(cxg_recall, cxg_precision, color='darkmagenta', lw=lw, label='c Xgb pr curve (area=%0.3f)' % cxg_average_precision)

    # 使用wh的xgboost分类结果
    plt.plot(whxg_recall, whxg_precision, color='yellow', lw=lw, label='wh Xgb pr curve (area=%0.3f)' % whxg_average_precision)

    # 使用whxy的xgboost分类结果
    # plt.plot(whxyxg_recall, whxyxg_precision, color='crimson', lw=lw, label='whxy Xgb pr curve (area=%0.3f)' % whxyxg_average_precision)

    # SVM分类结果
    plt.plot(svm_recall, svm_precision, color='green', lw=lw, label='SVM pr curve (area=%0.3f)' % svm_average_precision)

    # LR分类结果
    plt.plot(lr_recall, lr_precision, color='darkblue', lw=lw, label='LR pr curve (area=%0.3f)' % lr_average_precision)

    # MLP分类结果
    plt.plot(mlp_recall, mlp_precision, color='aquamarine', lw=lw, label='MLP pr curve (area=%0.3f)' % mlp_average_precision)

    # center MLP 分类结果
    plt.plot(c_mlp_recall, c_mlp_precision, color='black', lw=lw, label='c MLP pr curve (area=%0.3f)' % c_mlp_average_precision)



    plt.xlabel('Recall')
    plt.ylabel('Precision')
    plt.ylim([0.0, 1.05])
    plt.xlim([0.0, 1.0])
    plt.title('PR')
    plt.legend(loc='best')

    plt.show()


if __name__ == '__main__':
    # two_roc_curve()
    # two_pr_curve()

    # 绘制某模型ROC曲线
    labels = np.load('D:/lung_cancer/pytorch_code/two_result/two_other_maniflod_1.2_labels.npy')
    preds = np.load('D:/lung_cancer/pytorch_code/two_result/two_other_manifold_1.2_preds.npy')
    auc_curve(labels, preds)

    report = my_classfication_report(labels, preds, 0.2)

    print(report)

    matrix = my_confusion_matrix(labels, preds, 0.2)

    print(matrix)

    # 绘制人工提取特征的roc
    # two_roc_curve2()

    # 绘制自动提取特征的roc
    # two_roc_curve3()

